function todoListReducer(data) {
    function changeCheckbox(id) {
        return data.tdData.map(item => {
            if (item.id == id) {
                item.completed = !item.completed;
            }

            return item;
        });
    }

    function removeTodo(id) {
        return data.tdData.filter(item => item.id != id);
    }

    function addTodo(obj) {
        data.tdData.push(obj);
    }

    return {
        changeCheckbox,
        removeTodo,
        addTodo
    }
}

export default todoListReducer;

